import request from "@/utils/request";
// 根据考试ID预览试卷
export function previewExamPaper(examId) {
  return request({
    url: '/exam/manager/previewExamPaper/' + examId,
    method: 'get'
  })
}
// 修改试卷发布状态
export function changePublish(id, publish) {
  return request({
    url: `/exam/manager/changePublish/${id}/${publish}`,
    method: "put",
  });
}

// 查询试卷列表
export function listPaper(query) {
  return request({
    url: "/exam/paper/list",
    method: "get",
    params: query,
  });
}

// 查询试卷详细
export function getPaper(id) {
  return request({
    url: "/exam/paper/" + id,
    method: "get",
  });
}

// 新增试卷
export function addPaper(data) {
  return request({
    url: "/exam/paper",
    method: "post",
    data: data,
  });
}

// 修改试卷
export function updatePaper(data) {
  return request({
    url: "/exam/paper",
    method: "put",
    data: data,
  });
}

// 删除试卷
export function delPaper(id) {
  return request({
    url: "/exam/paper/" + id,
    method: "delete",
  });
}

// 新增试卷大题
export function addPaperTitle(data) {
  return request({
    url: "/exam/paper/addTitle",
    method: "post",
    data: data,
  });
}

// 排序上移下移
export function sortPaperTitle(titleId, type) {
  return request({
    url: "/exam/paper/sortTitle/" + titleId + "/" + type,
    method: "put",
  });
}

//移除大题
export function removePaperTitle(titleId) {
  return request({
    url: "/exam/paper/removeTitle/" + titleId,
    method: "delete",
  });
}

//根据考试Id获取试卷信息
export function getPaperByExamId(examId) {
  return request({
    url: "/exam/paper/getPaperByExamId/" + examId,
    method: "get",
  });
}

//批量修改试卷大题分数
export function setTitleAvgScore(titleId, titleType, avgScore) {
  return request({
    url:
      "/exam/paper/setTitleAvgScore/" +
      titleId +
      "/" +
      titleType +
      "/" +
      avgScore,
    method: "put",
  });
}

//修改大题的选项乱序
export function changeOptionUnsort(titleId, optionUnsort) {
  return request({
    url: "/exam/paper/changeOptionUnsort/" + titleId + "/" + optionUnsort,
    method: "put",
  });
}

//修改大题的试题乱序
export function changeTopicUnsort(titleId, topicUnsort) {
  return request({
    url: "/exam/paper/changeTopicUnsort/" + titleId + "/" + topicUnsort,
    method: "put",
  });
}

//修改大题标题
export function editTitleName(titleId, titleName) {
  return request({
    url: "/exam/paper/editTitle",
    method: "put",
    data: { title: titleName, id: titleId },
  });
}
